﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ShowProduct : System.Web.UI.Page
{
	private SqlConnection _connection = new SqlConnection();

    protected void Page_Load(object sender, EventArgs e)
    {
		if(!Page.IsPostBack)
		{
			ShowProductDetails(Request.QueryString["id"]);
		}

    }

	private void ShowProductDetails(string productId)
	{
		string strConnectionString = "server=127.0.0.1;uid=sa;pwd=liuxiaozeng;database=NorthwindCHS";
		_connection.ConnectionString = strConnectionString;

		SqlDataAdapter dataAdapter = new SqlDataAdapter(@"SELECT * FROM 产品 WHERE 产品ID=" + productId, _connection);
		DataSet ds = new DataSet();
		dataAdapter.Fill(ds, "Product");

		for(int i = 0; i < ds.Tables["Product"].Columns.Count;i++)
		{
			Response.Write(ds.Tables["Product"].Columns[i].ColumnName + ":" + ds.Tables["Product"].Rows[0][i].ToString() + "<br/>");
		}

	}
}
